{"ast":null,"code":"import _objectSpread from\"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/objectSpread2.js\";import _slicedToArray from\"/Users/poppie/Desktop/development/messenger/app/frontend/node_modules/@babel/runtime/helpers/esm/slicedToArray.js\";import React from\"react\";import{ContactsBlock}from\"../components/\";import{Context}from\"../index\";import{observer}from\"mobx-react-lite\";import{jsx as _jsx}from\"react/jsx-runtime\";var Contacts=function Contacts(props){var _React$useContext=React.useContext(Context),store=_React$useContext.store;var _React$useState=React.useState(false),_React$useState2=_slicedToArray(_React$useState,2),flag=_React$useState2[0],setFlag=_React$useState2[1];var _React$useState3=React.useState(),_React$useState4=_slicedToArray(_React$useState3,2),addRequests=_React$useState4[0],setAddRequests=_React$useState4[1],_React$useState5=React.useState(),_React$useState6=_slicedToArray(_React$useState5,2),sentRequests=_React$useState6[0],setSentRequests=_React$useState6[1],_React$useState7=React.useState(),_React$useState8=_slicedToArray(_React$useState7,2),allRequests=_React$useState8[0],setAllRequests=_React$useState8[1];React.useEffect(function(){if(!flag&&store.getChats().items===undefined){store.getChatsFromAPI().then();}else{setFlag(true);}// eslint-disable-next-line react-hooks/exhaustive-deps\n},[]);React.useEffect(function(){var tempAddRequests={items:[]},tempSentRequests={items:[]},tempAllRequests={items:[]};if(store.getContacts()&&store.getContacts().items){store.getContacts().items.forEach(function(item,index){if(item.toUser.id===store.getProfile().id&&!item.status){tempAddRequests.items[index]=item;}else if(item.fromUser.id===store.getProfile().id&&!item.status){tempSentRequests.items[index]=item;}else{tempAllRequests.items[index]=item;}});}setAddRequests(_objectSpread(_objectSpread({},addRequests),tempAddRequests));setSentRequests(_objectSpread(_objectSpread({},sentRequests),tempSentRequests));setAllRequests(_objectSpread(_objectSpread({},allRequests),tempAllRequests));// eslint-disable-next-line react-hooks/exhaustive-deps\n},[store.contacts]);return/*#__PURE__*/_jsx(ContactsBlock,{currentUser:store.getProfile(),addRequestList:addRequests||{items:[]},sentRequestList:sentRequests||{items:[]},allAcceptedList:allRequests||{items:[]}});};export default observer(Contacts);","map":{"version":3,"names":["React","ContactsBlock","Context","observer","Contacts","props","useContext","store","useState","flag","setFlag","addRequests","setAddRequests","sentRequests","setSentRequests","allRequests","setAllRequests","useEffect","getChats","items","undefined","getChatsFromAPI","then","tempAddRequests","tempSentRequests","tempAllRequests","getContacts","forEach","item","index","toUser","id","getProfile","status","fromUser","contacts"],"sources":["/Users/poppie/Desktop/development/messenger/app/frontend/src/containers/Contacts.tsx"],"sourcesContent":["import React from \"react\";\nimport {ContactsBlock} from \"../components/\";\nimport {Context} from \"../index\";\nimport {observer} from \"mobx-react-lite\";\nimport {ContactListResponse} from \"../models/response/ContactListResponse\";\n\nconst Contacts:React.FC = (props) => {\n    const {store} = React.useContext(Context);\n    const [flag, setFlag] = React.useState<boolean>(false);\n\n    const [addRequests, setAddRequests] = React.useState<ContactListResponse>(),\n          [sentRequests, setSentRequests] = React.useState<ContactListResponse>(),\n          [allRequests, setAllRequests] = React.useState<ContactListResponse>();\n\n    React.useEffect(() => {\n        if (!flag && store.getChats().items === undefined) {\n            store.getChatsFromAPI().then();\n        } else {\n            setFlag(true);\n        }\n        // eslint-disable-next-line react-hooks/exhaustive-deps\n    }, []);\n\n    React.useEffect(() => {\n\n        let tempAddRequests = {items: []} as ContactListResponse,\n            tempSentRequests = {items: []} as ContactListResponse,\n            tempAllRequests = {items: []} as ContactListResponse;\n\n        if (store.getContacts() && store.getContacts().items) {\n            store.getContacts().items.forEach((item, index) => {\n                if (item.toUser.id === store.getProfile().id && !item.status) {\n                    tempAddRequests.items[index] = item;\n                } else if (item.fromUser.id === store.getProfile().id && !item.status) {\n                    tempSentRequests.items[index] = item;\n                } else {\n                    tempAllRequests.items[index] = item;\n                }\n            });\n        }\n\n        setAddRequests({\n            ...addRequests,\n            ...tempAddRequests\n        });\n        setSentRequests({\n            ...sentRequests,\n            ...tempSentRequests\n        });\n        setAllRequests({\n            ...allRequests,\n            ...tempAllRequests\n        });\n\n        // eslint-disable-next-line react-hooks/exhaustive-deps\n    }, [store.contacts]);\n\n\n    return (\n        <ContactsBlock\n            currentUser={store.getProfile()}\n            addRequestList={addRequests || {items: []}}\n            sentRequestList={sentRequests || {items: []}}\n            allAcceptedList={allRequests || {items: []}}\n        />\n    );\n\n};\n\nexport default observer(Contacts);"],"mappings":"2RAAA,MAAOA,MAAK,KAAM,OAAO,CACzB,OAAQC,aAAa,KAAO,gBAAgB,CAC5C,OAAQC,OAAO,KAAO,UAAU,CAChC,OAAQC,QAAQ,KAAO,iBAAiB,CAAC,2CAGzC,GAAMC,SAAiB,CAAG,QAApBA,SAAiB,CAAIC,KAAK,CAAK,CACjC,sBAAgBL,KAAK,CAACM,UAAU,CAACJ,OAAO,CAAC,CAAlCK,KAAK,mBAALA,KAAK,CACZ,oBAAwBP,KAAK,CAACQ,QAAQ,CAAU,KAAK,CAAC,oDAA/CC,IAAI,qBAAEC,OAAO,qBAEpB,qBAAsCV,KAAK,CAACQ,QAAQ,EAAuB,qDAApEG,WAAW,qBAAEC,cAAc,sCACMZ,KAAK,CAACQ,QAAQ,EAAuB,qDAAtEK,YAAY,qBAAEC,eAAe,sCACEd,KAAK,CAACQ,QAAQ,EAAuB,qDAApEO,WAAW,qBAAEC,cAAc,qBAElChB,KAAK,CAACiB,SAAS,CAAC,UAAM,CAClB,GAAI,CAACR,IAAI,EAAIF,KAAK,CAACW,QAAQ,EAAE,CAACC,KAAK,GAAKC,SAAS,CAAE,CAC/Cb,KAAK,CAACc,eAAe,EAAE,CAACC,IAAI,EAAE,CAClC,CAAC,IAAM,CACHZ,OAAO,CAAC,IAAI,CAAC,CACjB,CACA;AACJ,CAAC,CAAE,EAAE,CAAC,CAENV,KAAK,CAACiB,SAAS,CAAC,UAAM,CAElB,GAAIM,gBAAe,CAAG,CAACJ,KAAK,CAAE,EAAE,CAAwB,CACpDK,gBAAgB,CAAG,CAACL,KAAK,CAAE,EAAE,CAAwB,CACrDM,eAAe,CAAG,CAACN,KAAK,CAAE,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